<?php
  class Model_rate extends CI_Model{
	  protected $_table = "tbl_tickets";
	  protected $_train = "tbl_trains";
	  public function __construct(){
		  parent::__construct();
		  $this->load->database();
	  }
	  public function getdata($id){
		  $this->db->where("tick_id",$id);
		  return $this->db->get($this->_table)->row_array();
	  }
	  public function gettrain($id){
		  $this->db->where("train_id",$id);
		  return $this->db->get($this->_train)->row_array();
	  }
	  public function getstart($trainid,$type,$startdate){
		 $this->db->where("trainid",$trainid);
		 $this->db->where("ticktype",$type);
		 $this->db->where("ticknum >",0);
		 $this->db->where("tickdate",$startdate);
		 return $this->db->get($this->_table)->result_array();
	  }
	  public function getend($trainid,$type,$endate){
		 $this->db->where("trainid",$trainid);
		 $this->db->where("ticktype",$type);
		 $this->db->where("ticknum >",0);
		 $this->db->where("tickdate",$endate);
		 return $this->db->get($this->_table)->result_array();
	  }
  }
?>